<?php
include("utils.php");
if($_SESSION['siteuserId']=="")
{
	header("location:index.php");
}
if($_SESSION['langname']=="")
{
	$language_url="languages/"."english".'/sell_website_add_language.php';
}
else
{
	$language_url="languages/".$_SESSION['langname'].'/sell_website_add_language.php';
}
include("$language_url");
if($_POST['mode']=="save_landing_page")
{
	save_landing_page();
}
else
{
	main_content("main();");
}

function main()
{
$sql="select * from adspace_landing_page where landingId='".$_REQUEST['id']."' ";
$query=mysql_query($sql);
$rec=mysql_fetch_array($query);
?><script language=JavaScript src="JavaScripts/picker.js"></script><script language="JavaScript">

function changeValue(strValue, strLength, countId) {
//alert(countId);
        if (strValue.length <= strLength) {
            if (strValue != null) {

				document.getElementById("description_final").innerHTML=strValue;
                document.getElementById(countId).innerHTML = (strLength - strValue.length);
                if (countId == 'tagsCount' && (strValue.indexOf('"') >= 0 || strValue.indexOf("'") >= 0 || strValue.indexOf("|") >= 0 || strValue.indexOf("\\") >= 0)) {
                    var message = "Invalid tag, please re-enter tags without |, \', \", \\ in it.";
                    alert(message);
            }
            }
        }
        else {
            document.getElementById(countId).innerHTML = "<span style=\"color:red\">Too many characters for description!</span>";
        }
    }

function changeValue1(strValue, strLength, countId) {
document.getElementById("site_title_show").innerHTML=strValue;
    }
function changeValue2(strValue, strLength, countId) {
document.getElementById("site_label_final").innerHTML=strValue;
    }
function changeValue_gen(strValue, strLength, countId) {
document.getElementById("lead_generation_final").innerHTML=strValue;
    }
function IsNumeric(sText)

{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function changeValue3(strValue, strLength, countId) {


document.getElementById("site_phone_final").innerHTML=strValue;

document.getElementById('site_phone_final_hrf').href="tel:"+strValue;

    }

function changeValue4(strValue, strLength, countId)
{
	document.getElementById("site_headline_final").innerHTML=strValue;
}

function changeValue5(strValue, strLength, countId)
{
	document.getElementById("site_headline_final").innerHTML=strValue;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   }

function check()
{
//alert("test");
	if(document.tcp_test.page_name.value=="")
	{
		document.getElementById('text_err').innerHTML="please enter landing page name";
		document.tcp_test.page_name.focus();
		return false;
	}

	if(document.tcp_test.site_title.value=="Title")
	{
		document.getElementById('text_err').innerHTML="please enter site title name";
		document.tcp_test.site_title.value="";
		document.tcp_test.site_title.focus();
		return false;
	}

	/* if(document.tcp_test.site_label.value=="Call")
	{
		document.getElementById('text_err').innerHTML="please enter label";
		document.tcp_test.site_label.value="";
		document.tcp_test.site_label.focus();
		return false;
	} */

	/* if(document.tcp_test.site_phone.value=="4155551212")
	{
		document.getElementById('text_err').innerHTML="please enter Phone number";
		document.tcp_test.site_phone.value="";
		document.tcp_test.site_phone.focus();
		return false;
	} */

	/* if(document.tcp_test.site_phone.value!="")
		{
			if (!IsNumeric(document.tcp_test.site_phone.value)) 
   			{
				document.getElementById('text_err').innerHTML="please enter only integer number";
				document.tcp_test.site_phone.value="";
				document.tcp_test.site_phone.focus();
				return false;
			}
		} */

	/* if(document.tcp_test.site_headline.value=="Headline")
	{
		document.getElementById('text_err').innerHTML="please enter Headline";
		document.tcp_test.site_headline.value="";
		document.tcp_test.site_headline.focus();
		return false;
	} */

	return true;
}

function generatePreview(argu)
{

		var num=argu;
		if(num==15)
		{
			document.getElementById('s_title1').innerHTML='15';	
			document.getElementById('s_title2').innerHTML='30';
			document.getElementById('s_title3').innerHTML='45';
			document.getElementById('s_title4').innerHTML='60';
			document.getElementById('s_title5').innerHTML='75';
		}
		else if(num==30)
		{
			document.getElementById('s_title1').innerHTML='30';	
			document.getElementById('s_title2').innerHTML='60';
			document.getElementById('s_title3').innerHTML='90';
			document.getElementById('s_title4').innerHTML='120';
			document.getElementById('s_title5').innerHTML='150';
		}
		
}

function generatePreview_row(argu)
{
//alert(argu);
var num=argu;
if(num==1)
{
	document.getElementById('t_title1').style.display='';	
	document.getElementById('t_title2').style.display='none';
	document.getElementById('t_title3').style.display='none';
	document.getElementById('t_title4').style.display='none';
	document.getElementById('t_title5').style.display='none';
}
else if(num==2)
{
	document.getElementById('t_title1').style.display='';	
	document.getElementById('t_title2').style.display='';
	document.getElementById('t_title3').style.display='none';
	document.getElementById('t_title4').style.display='none';
	document.getElementById('t_title5').style.display='none';
}
else if(num==3)
{
	document.getElementById('t_title1').style.display='';		
	document.getElementById('t_title2').style.display='';
	document.getElementById('t_title3').style.display='';
	document.getElementById('t_title4').style.display='none';
	document.getElementById('t_title5').style.display='none';
}
else if(num==4)
{
	document.getElementById('t_title1').style.display='';	
	document.getElementById('t_title2').style.display='';
	document.getElementById('t_title3').style.display='';
	document.getElementById('t_title4').style.display='';
	document.getElementById('t_title5').style.display='none';
}
else if(num==5)
{
	document.getElementById('t_title1').style.display='';	
	document.getElementById('t_title2').style.display='';
	document.getElementById('t_title3').style.display='';
	document.getElementById('t_title4').style.display='';
	document.getElementById('t_title5').style.display='';
}

}

</script>


<table width="90%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td valign="top" align="center"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="20%" valign="top"><?php include("left_pannel.php"); ?></td>
					<td width="20px">&nbsp;</td>
                    <td valign="top"><table width="98%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="11"><img src="images/PinkBorderTopLeft.jpg" alt="" width="11" height="11"></td>
                          <td class="PinkBoxTopBg"><img src="images/spacer.gif" alt="" width="10" height="11"></td>
                          <td width="11"><img src="images/PinkBorderTopRight.jpg" alt="" width="11" height="11"></td>
                        </tr>
                      </table></td>
                  </tr>
                  <tr>
                    <td class="PinkTwosideBorder BoxContent" valign="top"><form name="tcp_test" method="POST" action="" onsubmit="return check();" enctype="multipart/form-data">
<input type="hidden" name="mode" value="save_landing_page"><table class="center" cellspacing="0" cellpadding="0"  width="100%">
  
  <tr>
    <td align="left" valign="top">
    	
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
           <tr>
           <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
				
				<?php
				if($GLOBALS['msg']!="")
				{
				?>
				<tr>
				<td width="29">&nbsp;</td>
				<td class="font-12 black advertise_tableTxt" align="center">
				<?php
				echo $GLOBALS['msg'];
				?>
				</td>
                </tr>
				<?php
				}
				if($GLOBALS['msg1']!="")
				{
				?>
				<tr>
				<td width="29">&nbsp;</td>
				<td class="font-12 black advertise_tableTxt" align="center">

				<?php
				echo $GLOBALS['msg1'];
				?>
				</td>
                </tr>

				<?php
				}
				if($GLOBALS['msg2']!="")
				{
				?>

				<tr>
				<td width="29">&nbsp;</td>
				<td class="font-12 black advertise_tableTxt" align="center"><strong>URL: http://www.esolz.org/admobweb_new/landing_page_rss.php?id=<?php echo $GLOBALS['msg2'];?></strong></td>
                </tr>
				
				<?php
				}
				if($GLOBALS['msg2']!="")
				{
				?>

				<tr>
				<td width="29">&nbsp;</td>
				<td class="font-12 black advertise_tableTxt" align="center"><a href="create_landing_page.php">Back</a></td>
                </tr>
				
				<?php
				}
				?>

               <tr>
				<td width="29"><img src="images/TitleArrowLeft.jpg" alt="" width="29" height="30"></td>
				<td class="MarketTitleBg">Landing Page Builder</td>
                </tr>


                </table>
		  </td>
          </tr>
		<tr><TD align="center">

		<table width="98%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                
                                <td valign="top"><table border="0" cellspacing="0" cellpadding="0" >
									
									<?php
									if($GLOBALS['msg2']!="")
				{
				?>
									<tr>
                                    <td height="30" colspan="5" align="center" style="padding-top:20px;padding-bottom:20px;" id="text_err"><?php echo $GLOBALS['msg'];?></td>
                                  </tr>
									<?php
										}
									?>

									<tr>
                                    <td height="30" colspan="5" align="center" style="padding-top:20px;padding-bottom:20px;" class="ERR"><font id="text_err"></font></td>
                                  </tr>

									 <tr>
                                    <td width="100" height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg" nowrap="true">Landing Page Name:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td width="14">&nbsp;</td>
                                    <td><input name="page_name" type="text" class="InputBox" id="page_name" value="<?php echo $rec['pageName'];?>"></td>
                                    <td width="11">&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>


                                  <tr>
                                    <td width="100" height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Site Title Name:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td width="14">&nbsp;</td>
                                    <td><input name="site_title" type="text" class="InputBox" id="site_title" onchange="isChanged=true;" onkeyup="javascript:changeValue1(this.value, 255, 'site_title_count');" value="
									<?php
									if($rec['pageTitle']!="")
									{
									 	echo $rec['pageTitle'];
									}
									else
									{
										echo "Title";
									}
									?>
									"></td>
                                    <td width="11">&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

								<!--<tr>
                                    <td width="100" height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Rss Feed:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td width="14">&nbsp;</td>
                                    <td><input name="site_title" type="text" class="InputBox" id="site_title" onchange="isChanged=true;" onkeyup="javascript:changeValue1(this.value, 255, 'site_title_count');" value="
									<?php
									if($rec['pageTitle']!="")
									{
									 	echo $rec['pageTitle'];
									}
									else
									{
										echo "Title";
									}
									?>
									"></td>
                                    <td width="11">&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>-->


								<tr>
                                    <td width="100" height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Update Every:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td width="14">&nbsp;</td>
                                    <td class="inner_contentArea" nowrap="true" align="left"><select tabindex="1" name="update_time_in_minutes" id="update_time_in_minutes" style="min-width: 110px;max-width: 110px;" onchange="generatePreview(this.value)" class="InputBox">
    	              	<option value="15">15 Minutes</option>
						<option value="30">30 Minutes</option>
        	        	</select>
						&nbsp;
						Stories to display:  
						&nbsp;
					<select tabindex="1" name="page_modules" id="page_modules" style="min-width: 40px;max-width: 40px;" onchange="generatePreview_row(this.value)" class="InputBox">
    	              	<option value="1">1</option>
						<option value="2">2</option>
						<option value="3">3</option>
						<option value="4">4</option>
						<option value="5">5</option>
    	            	</select> </td>
                                    <td width="11">&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
	
                                  <tr>
                                    <td height="30">&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td align="left" valign="bottom"><input name="button3" type="submit" class="SubmitInputButton" id="button3" value="Submit">&nbsp;
									<input name="button3" type="button" class="SubmitInputButton" id="button3" value="Cancel" onclick="javascript: window.location='create_landing_page.php';">
									</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  
                                </table></td>
								<td valign="top"style="padding-top:20;">
								<table width="100%" cellspacing="0" cellpadding="0" style="border:1px;">
		
                                      <tr>
										<td>
											<table width="100%" cellspacing="0" cellpadding="0" border="1">
								
											<tr>
											<td align="center">
											<table width="200" cellspacing="0" cellpadding="0" border="0">

											<tr>
										<td bgcolor="Silver">
											<div id="site_title_show"><?php
									if($rec['pageName']!="")
									{
									 	echo $rec['pageName'];
									}
									else
									{
										echo "Title";
									}
									?></div>
										</td>
									  </tr>
										<tr>
										<td id="t_title1" style="padding-top:10px;" class="inner_contentArea">
										<a href="#">Story Title 1</a> (<span id="s_title1">15</span> minutes ago)
										</td>
										</tr>

										<tr>
										<td id="t_title2" style="padding-top:10px;display:none;" class="inner_contentArea">
										<a href="#">Story Title 2</a> (<span id="s_title2">15</span> minutes ago)
										</td>
										</tr>

										<tr>
										<td id="t_title3" style="padding-top:10px; display:none;" class="inner_contentArea">
										<a href="#">Story Title 3</a> (<span id="s_title3">15</span> minutes ago)
										</td>
										</tr>

										<tr>
										<td id="t_title4" style="padding-top:10px;display:none;" class="inner_contentArea">
										<a href="#">Story Title 4</a> (<span id="s_title4">15</span> minutes ago)
										</td>
										</tr>
										<tr>
										<td id="t_title5" style="padding-top:10px;display:none;" class="inner_contentArea">
										<a href="#">Story Title 5</a> (<span id="s_title5">15</span> minutes ago)
										</td>
										</tr>															
											</table>
											</td>
											</tr>
											</table>
										</td>
									  </tr>
								</table>
								</td>
                              </tr>
                            </table>

		</TD></tr>
		</table>

    </td>
  </tr>

</table></form></td>
                  </tr>
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="11"><img src="images/PinkBorderBottomLeft.jpg" alt="" width="11" height="11"></td>
                          <td class="PinkBoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="11"></td>
                          <td width="11"><img src="images/PinkBorderBottomRight.jpg" alt="" width="11" height="11"></td>
                        </tr>
                      </table></td>
                  </tr>
                </table></td>
                    <td>&nbsp;</td>
                    </tr>
                </table></td>
              </tr>
            </table>


<?php
}
function save_landing_page()
{

if($_REQUEST['id']=="")
{


   $query="insert into adspace_landing_page set
		UserId='".$_SESSION['siteuserId']."' , 
		pageName='".$_POST['page_name']."',
		pageTitle='".$_POST['site_title']."',
		rss_time='".$_POST['update_time_in_minutes']."',
		rss_no='".$_POST['page_modules']."',
		type='rss_feed',
		created_date=NOW()
		";
mysql_query($query);
$id=mysql_insert_id();


$GLOBALS['msg']="Landing page created successfully.";
$GLOBALS['msg1']="Your landing page url is";
$GLOBALS['msg2']="$id";

$landing_url='http://www.esolz.org/admobweb_new/landing_page_rss.php?id='.$id;

$update_url="update adspace_landing_page set landing_url = '".$landing_url."' where landingId = '".$id."'";
mysql_query($update_url);
}
else
{

	 $query="update adspace_landing_page set
		UserId='".$_SESSION['siteuserId']."' , 
		pageName='".$_POST['page_name']."',
		pageTitle='".$_POST['site_title']."',
		rss_time='".$_POST['update_time_in_minutes']."',
		rss_no='".$_POST['page_modules']."',
		type='rss_feed' where landingId='".$_REQUEST['id']."'
		";
mysql_query($query);
$GLOBALS['msg']="Landing page updated successfully.";
$GLOBALS['msg1']="Your landing page url is";
$GLOBALS['msg2']="$_REQUEST[id]";

}

main_content("main();");

}
?>
